package xin.nick.service.impl;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import xin.nick.api.UserServiceApi;
import xin.nick.service.ProjectService;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Nick
 * @since 2023/4/16
 */
@Service
@RequiredArgsConstructor
public class ProjectServiceImpl implements ProjectService {

    private final UserServiceApi userServiceApi;

    /**
     * 根据用户名获取项目列表
     * @param username
     * @return List<String>
     */
    @Override
    public List<String> getProjectListByUsername(String username) {
        List<String> allUserList = userServiceApi.getAllList(username);
        return allUserList.parallelStream().map(user -> user + "的项目").collect(Collectors.toList());
    }
}
